//
//  APPLENavigationViewController.swift
//  123
//
//  Created by pangjiaxing on 15/12/27.
//  Copyright © 2015年 pangjiaxing. All rights reserved.
//

import UIKit

class APPLENavigationViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        
    }

    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        var backtitle="返回"
        
        if childViewControllers.count>0 {
           
            if childViewControllers.count == 1 {
                backtitle = childViewControllers.first!.title ?? "返回"
                viewController.navigationItem.leftBarButtonItem=UIBarButtonItem(imageName: "navigationbar_back_withtext", title: backtitle, targat: self, action: "pop")
            }
            viewController.navigationItem.leftBarButtonItem=UIBarButtonItem(imageName: "navigationbar_back_withtext", title: backtitle, targat: self, action: "pop")
        }
        
       super.pushViewController(viewController, animated: animated)
    }
    @objc private func pop(){
        
        popViewControllerAnimated(true)
        
    }
}
